Proper connect_port
[juce-lv2.git] / juce / source / extras / the jucer / src / ui / jucer_SnapGridPainter.cpp
blobe40d877dd892c1535e735e6ab9d16c840afa0eb7
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_SnapGridPainter.h"
30 //==============================================================================
31 SnapGridPainter::SnapGridPainter()
32 : snapGridSize (-1),
33 snapShown (false),
34 backgroundFill (0)
38 SnapGridPainter::~SnapGridPainter()
42 bool SnapGridPainter::updateFromDesign (JucerDocument& design)
44 if (snapGridSize != design.getSnappingGridSize()
45 || snapShown != (design.isSnapShown() && design.isSnapActive (false)))
47 snapGridSize = design.getSnappingGridSize();
48 snapShown = design.isSnapShown() && design.isSnapActive (false);
50 backgroundFill = Image();
51 return true;
54 return false;
57 void SnapGridPainter::updateColour()
59 backgroundFill = Image();
62 void SnapGridPainter::draw (Graphics& g, PaintRoutine* backgroundGraphics)
64 if (backgroundFill.isNull() && snapShown)
66 backgroundFill = Image (Image::ARGB, snapGridSize, snapGridSize, true);
68 Graphics g (backgroundFill);
70 Colour col (Colours::black);
72 if (backgroundGraphics != 0)
73 col = backgroundGraphics->getBackgroundColour().contrasting();
75 if (snapGridSize > 2)
77 g.setColour (col.withAlpha (0.1f));
78 g.drawRect (0, 0, snapGridSize + 1, snapGridSize + 1);
81 g.setColour (col.withAlpha (0.35f));
82 g.setPixel (0, 0);
85 if (backgroundFill.isValid())
87 g.setTiledImageFill (backgroundFill, 0, 0, 1.0f);
88 g.fillAll();